package fr.unice.polytech.chord.samples.commands;

import java.util.ArrayList;
import java.util.List;

import fr.unice.polytech.chord.samples.managers.Manager;

/**
 * A Command is a set of operations that a {@link Manager} can execute.
 * 
 * @author Anthony Parisy
 * @author Laurent Pellegrino
 * @author Marc Valdener
 * 
 * @version 10/30/2009
 */
public abstract class Command {
	private String argumentsLine = "";
	private String[] commandArguments = new String[] {};

	private List<String> commandShortcuts;
	private String description;
	private Manager manager;

	public Command(Manager manager, String description,
			String[] commandShortcuts, String[] commandArguments) {
		this.commandArguments = commandArguments;
		this.commandShortcuts = new ArrayList<String>();
		this.description = description;
		this.manager = manager;

		for (String shortcut : commandShortcuts) {
			this.commandShortcuts.add(shortcut);
		}
	}

	public abstract void execute(String... args);

	public List<String> getCommandShortcuts() {
		return this.commandShortcuts;
	}

	public String getDescription() {
		return this.description;
	}

	public Manager getManager() {
		return this.manager;
	}

	public String[] getCommandArguments() {
		return this.commandArguments;
	}

	public String getArgumentsLine() {
		return this.argumentsLine;
	}

	public void setArgumentsLine(String argumentsLine) {
		this.argumentsLine = argumentsLine;
	}

	public void printInfo(String info) {
		System.out.print("*** ");
		System.out.println(info);
	}
}
